package com.xinlang.excel.io;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

import com.xinlang.excel.RawTable;
import com.xinlang.excel.Table;

//输出<String, String, Object>类型Table的Writer
public class TextTableWriter extends TextRawTableWriter<String, String, Object> implements TableWriter {

	public TextTableWriter(OutputStream out) throws IOException {
		super(out);
	}

	public TextTableWriter(PrintStream out) throws IOException {
		super(out);
	}

	public TextTableWriter(String filename) throws IOException {
		super(filename);
	}

	static public void main(String[] args) throws IOException {
		// TextTableWriter writer = new TextTableWriter("sample.txt");
		TextTableWriter writer = new TextTableWriter(System.out);
		Table table = new Table();
		table.put("1", "A", "1A");
		table.put("2", "B", "2B");
		table.put("3", "C", "3C");
		table.put("2", "C", "2C");
		writer.write(table);

		System.out.println();
		// System.err.println("done!");

		table.orderBy("C", false); // 按照"C"升序排列
		writer.write(table);
	}

	@Override
	public void write(Table table) throws IOException {
		super.write((RawTable<String, String, Object>) table);
	}

}
